home *** CD-ROM | disk | FTP | other *** search
-
- ; ---------------------------------------------------------------------
- ; Complex example of double-buffered animation - support@blitzbasic.com
- ; ---------------------------------------------------------------------
-
- ; Not complex at all, just complex compared to the simple example.
- ; (Refer to that example for more detailed explanations of the basics
- ; used here.)
-
- ; To see this code without all the comments, see "complex example
- ; uncommented.bb"...
-
- ; USE THE CURSOR KEYS TO CONTROL THE ROCKET!
-
- ; ---------------------------------------------------------------------
- ; Open a 640 x 480 display...
- ; ---------------------------------------------------------------------
-
- Graphics 640, 480
-
- ; ---------------------------------------------------------------------
- ; Set up double-buffered animation
- ; ---------------------------------------------------------------------
-
- SetBuffer BackBuffer ()
-
- ; ---------------------------------------------------------------------
- ; Load images and set transparent mask where appropriate...
- ; ---------------------------------------------------------------------
-
- background = LoadImage ("george.bmp")
-
- player = LoadImage ("rocket.bmp")
- MaskImage player, 255, 0, 255
-
- foreground = LoadImage ("xmas.bmp")
- MaskImage foreground, 255, 0, 255
-
- ; ---------------------------------------------------------------------
- ; Set player's start position...
- ; ---------------------------------------------------------------------
-
- ; We're using two 'variables' called x and y to store the player's
- ; position on screen. When we check for keypresses, we'll increase
- ; and decrease these values to change the player's position...
-
- x = 320
- y = 340
-
- ; ---------------------------------------------------------------------
- ; Main game loop
- ; ---------------------------------------------------------------------
-
- Repeat
-
- Cls
-
- ; -----------------------------------------------------------------
- ; Check keypresses...
- ; -----------------------------------------------------------------
-
- ; Here, we increase and decrease x and y when the cursors are
- ; pressed, then we draw the rocket at that x/y position... the key
- ; codes used are listed in the Help section. Try changing them to use
- ; different keys...
-
- If KeyDown (203) Then x = x - 1 ; Left cursor
- If KeyDown (205) Then x = x + 1 ; Right cursor
- If KeyDown (200) Then y = y - 1 ; Up cursor
- If KeyDown (208) Then y = y + 1 ; Down cursor
-
- ; -----------------------------------------------------------------
- ; Draw images in order, from furthest away to nearest...
- ; -----------------------------------------------------------------
-
- TileImage background
- DrawImage player, x, y
- DrawImage foreground, 0, 250
-
- Flip
-
- Until KeyHit (1)
-
- End